home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 December / 2004-12 CHIP.iso / Narzedzia systemowe / Inno Setup 5.0.4 Beta / isetup-5.0.4-beta.exe / {app} / Examples / CodeDll.iss < prev    next >
Text File  |  2004-02-06  |  2KB  |  54 lines

  1. ; -- CodeDll.iss --
  2. ;
  3. ; This script shows how to call DLL functions at runtime from a [Code] section.
  4.  
  5. [Setup]
  6. AppName=My Program
  7. AppVerName=My Program version 1.5
  8. DefaultDirName={pf}\My Program
  9. DisableProgramGroupPage=yes
  10. UninstallDisplayIcon={app}\MyProg.exe
  11.  
  12. [Files]
  13. Source: "MyProg.exe"; DestDir: "{app}"
  14. Source: "MyProg.hlp"; DestDir: "{app}"
  15. Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme
  16. Source: "MyDll.dll"; Flags: dontcopy
  17. ;Source: "MyDll.dll"; DestName: "MyDllWhichMightNotExist.dll"; Flags: dontcopy
  18.  
  19. [Code]
  20. const
  21.   MB_ICONINFORMATION = $40;
  22.  
  23. //importing a Windows API function
  24. function MessageBox(hWnd: Integer; lpText, lpCaption: String; uType: Cardinal): Integer;
  25. external 'MessageBoxA@user32.dll stdcall';
  26.  
  27. //importing a custom DLL function
  28. procedure MyDllFunc(hWnd: Integer; lpText, lpCaption: String; uType: Cardinal);
  29. external 'MyDllFunc@files:MyDll.dll stdcall';
  30.  
  31. //importing a function for a DLL which might not exist at runtime, see [Files] ('delay loading')
  32. procedure MyDelayLoadedFunc(hWnd: Integer; lpText, lpCaption: String; uType: Cardinal);
  33. external 'MyDllFunc@files:MyDllWhichMightNotExist.dll stdcall delayload';
  34.  
  35. function NextButtonClick(CurPage: Integer): Boolean;
  36. var
  37.   hWnd: Integer;
  38. begin
  39.   if CurPage = wpWelcome then begin
  40.     hWnd := StrToInt(ExpandConstant('{wizardhwnd}'));
  41.  
  42.     MessageBox(hWnd, 'Hello from Windows API function', 'MessageBoxA', MB_OK or MB_ICONINFORMATION);
  43.  
  44.     MyDllFunc(hWnd, 'Hello from custom DLL function', 'MyDllFunc', MB_OK or MB_ICONINFORMATION);
  45.  
  46.     try
  47.       MyDelayLoadedFunc(hWnd, 'Hello from delay loaded function', 'MyDllFunc', MB_OK or MB_ICONINFORMATION);
  48.     except
  49.       //handle missing dll here
  50.     end;
  51.   end;
  52.   Result := True;
  53. end;
  54.